package uc

import (
	"bytes"
	"thomas-mesh/pkg"
)

type Packet struct {
	ReqType    byte
	PacketId   uint32
	PacketType byte
	BodyLength uint32
	Body       []byte
}

type Protocol struct {
	Key   string
	Value *interface{}
}

func (p *Packet) Bytes() []byte {
	buffer := bytes.NewBuffer([]byte{})
	buffer.WriteByte(p.ReqType)
	buffer.Write(pkg.IntToBytes(p.PacketId))
	buffer.WriteByte(p.PacketType)
	buffer.Write(pkg.IntToBytes(p.BodyLength))
	buffer.Write(p.Body)
	return buffer.Bytes()
}
